package edu.xpu.compute.recommend.fontpage;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import edu.xpu.compute.recommend.common.annotation.Router;
import edu.xpu.compute.recommend.vo.LoginUserVo;

@Controller
public class IndexRouter {
	
	/**
	 * 用户注册
	 * @return
	 */
	@RequestMapping(value="register")
	public String register() {
		return "register";
	}
	
	/**
	 * 系统登录页面
	 * @return
	 */
	@RequestMapping(value="/")
	public String index() {
		return "login";
	}
	/**
	 * 后端管理首页
	 * @return
	 */
	@Router(value="adminIndex")
	public String adminIndex(HttpServletRequest request, ModelMap modelMap) {
		HttpSession session = request.getSession();
		if (session != null) {
			LoginUserVo vo = (LoginUserVo) session.getAttribute("SESSION_USER");
			modelMap.addAttribute("username", vo.getUserName());
		}
		return "admin/adminIndex";
	}
	/**
	 * 后端管理首页
	 * @return
	 */
	@Router(value="defaultPage")
	public String defaultPage() {
		return "admin/defaultPage";
	}
	/**
	 * 前端用户首页
	 * @return
	 */
	@Router(value="userIndex")
	public String userIndex(HttpServletRequest request, ModelMap modelMap) {
		HttpSession session = request.getSession();
		if (session != null) {
			LoginUserVo vo = (LoginUserVo) session.getAttribute("SESSION_USER");
			modelMap.addAttribute("username", vo.getUserName());
		}
		return "front/userIndex";
	}

}
